/**
 * @Title: BaseHelperFragment.java
 * @Package com.bxd365.helper.base
 * @Description: TODO(用一句话描述该文件做什么)
 * @author ChangJianlong
 * @date 2015-1-13 下午4:24:01 
 * @version V1.0
 */
package com.bxd.baodan.base;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;

import com.bxd.baodan.App;
import com.bxd.baodan.R;
import com.bxd.baodan.activity.WebViewPager;
import com.bxd.baodan.util.DialogUtil;
import com.bxd.baodan.util.ETUtil;
import com.bxd.baodan.util.ViewUtil;

/**
 * @author ChangJianlong
 * @ClassName: BaseHelperFragment
 * @Description: fragment 基类
 * @date 2015-1-13 下午4:24:01
 */
public class BaseHelperFragment extends Fragment {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setHasOptionsMenu(true);
	}

	protected void openActivity(Class<?> className) {
		Intent intent = new Intent(App.getContext(), className);
		startActivity(intent);
		if(getActivity()!=null){
			
			getActivity().overridePendingTransition(R.anim.slide_in_right,
					R.anim.slide_out_left);
		}
	}

	public void showToast(String string) {
		DialogUtil.getInstance().showToast(App.getContext(), string);
	}

	public void showSimpleDialog(String string) {
		if(getActivity()!=null){
			
			DialogUtil.getInstance().showSimpleDialog(getActivity(), string);
		}
	}

	public int getInt(EditText et) {
		return ETUtil.getInt(et);
	}

	public String getString(EditText et) {
		return ETUtil.getString(et);
	}

	public String getString(TextView et) {
		return ETUtil.getString(et);
	}

	public GridView getGridView(View view, int id) {
		return ViewUtil.getGridView(view, id);
	}

	public ListView findListView(View view, int id) {
		return ViewUtil.getListView(view, id);
	}

	public TextView getTextView(View view, int id) {
		return ViewUtil.getTextView(view, id);
	}

	public ImageView getImageView(View view, int id) {
		return ViewUtil.getImageView(view, id);
	}

	public ListView getListView(View view, int id) {
		return ViewUtil.getListView(view, id);
	}

	public Button getButton(View view, int id) {
		return ViewUtil.getButton(view, id);
	}

	public EditText getEditText(View view, int id) {
		return ViewUtil.getEditText(view, id);
	}

	public Spinner getSpinner(View view, int id) {
		return ViewUtil.getSpinner(view, id);
	}
	
	

	public RadioGroup getRadioGroup(View view, int id) {
		return ViewUtil.getRadioGroup(view, id);
	}

	public String getString(Spinner spinner) {
		return spinner.getSelectedItem().toString();
	}

	public int getInt(Spinner spinner) {
		return ViewUtil.getInt(spinner);
	}
	
	

	public boolean isEmpty(EditText... ets) {
		return ETUtil.isEmpty(ets);
	}

	public CheckBox getCheckBox(View view, int id) {
		return ViewUtil.getCheckBox(view, id);
	}

	public LinearLayout getLinearLayout(View view, int id) {
		return ViewUtil.getLinearLayout(view, id);
	}

//	protected void IntentWebViewActivity(String url) {
//		Intent intent = new Intent(getActivity(), WebViewPager.class);
//		intent.putExtra("loading_url", Utils.subStringUrl(getActivity(), url));
//		startActivity(intent);
//	}



	private void openWebViewActivity(String url) {
		Intent intent = new Intent(App.getContext(), WebViewPager.class);
		intent.putExtra("startUrl", url);
		startActivity(intent);
		if(getActivity()!=null){
			getActivity().overridePendingTransition(R.anim.slide_in_right,
					R.anim.slide_out_left);
		}
	}

	@Override
	public void startActivity(Intent intent) {
		super.startActivity(intent);
		// getActivity().overridePendingTransition(R.anim.slide_in_right,
		// R.anim.slide_out_left);
	}

	private boolean isSelected = false;

	public boolean isSelected() {
		return isSelected;
	}

	public void onSelected() {
		isSelected = true;
	}

	public void unSelected() {
		isSelected = false;
	}


}
